package com.lds.config.center.server.business.app.converter;

import com.lds.config.center.common.model.app.request.AppBaseCreateRequest;
import com.lds.config.center.server.business.app.entity.App;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class AppBaseCreateRequestToEntityConverter implements Converter<AppBaseCreateRequest, App> {

    @Override
    public App convert(AppBaseCreateRequest source) {
        LocalDateTime date = LocalDateTime.now();
        return App.builder()
                .creator(source.getCreator())
                .modifier(source.getModifier())
                .createTime(date)
                .updateTime(date)
                .name(source.getName())
                .desc(source.getDesc())
                .clusterId(source.getClusterId())
                .build();
    }

}


